/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.ipti.br.tag.bo;

import org.ipti.br.tag.dao.StreetFacade;
import org.ipti.br.tag.entity.City;
import org.ipti.br.tag.entity.Street;
import org.ipti.br.tag.entity.Zipcode;
import java.util.Calendar;
import java.util.List;
import javax.inject.Inject;
import javax.ejb.Stateless;
import javax.inject.Inject;

/**
 *
 * @author israel
 */
@Stateless
public class StreetBO {

    @Inject
    private StreetFacade streetDAO;

    public StreetFacade getStreetDAO() {
        return streetDAO;
    }
    
    public void create(Street street){
        getStreetDAO().create(street);
    }

    public Street createOrRefresh(String name, Zipcode zipcode) {
        Street street = searchByNameCity(name,zipcode.getCity().getId());

        if (street == null) {
            street = new Street(name,zipcode.getCity());
            getStreetDAO().create(street);
        }
        
        return street;
    }

    public void edit(Street street) {
        getStreetDAO().edit(street);
    }

    public void remove(Street street) {
        getStreetDAO().remove(street);
    }

    public Street find(Object id) {
        return getStreetDAO().find(id);
    }

    public List<Street> findAll() {
        return getStreetDAO().findAll();
    }

    public List<Street> findAllOrder() {
        return getStreetDAO().findAllOrder();
    }
    
    public Street searchByNameCity(String name, Long cityID) {
        return getStreetDAO().searchByNameCity(name, cityID);
    }
    
    public List<String> streetList(String name, City city) {
        return getStreetDAO().streetList(name, city);
    }
    
    public List<Street> modifiedStreetBetweenDate(Calendar initialDate, Calendar finalDate, Long serialNumber) {
        return getStreetDAO().modifiedStreetBetweenDate(initialDate, finalDate, serialNumber);
    }
}
